package com.yycx.module.bus.provider.handler.refund;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.mybatis.interceptor.DeleteInterceptor;
import com.yycx.common.mybatis.query.CriteriaDelete;
import com.yycx.module.bus.provider.service.BusOrderDetailsService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * 厂家返款删除扩展
 *
 * @author zyf
 */
@Component("refundPaymentDeleteHandler")
public class RefundPaymentDeleteHandler implements DeleteInterceptor {

    @Resource
    private BusOrderDetailsService orderDetailsService;

    @Override
    public void prepare(CriteriaDelete criteriaDelete, EntityMap entityMap) {
        Serializable[] paymentId = criteriaDelete.getIds();
        if(FlymeUtils.isNotEmpty(paymentId)) {
            //清空返款信息
            orderDetailsService.clearFankuanInfo(paymentId[0]);
        }
    }

    @Override
    public void complete(CriteriaDelete cq, EntityMap params) {

    }
}
